<template>
  <div style="width: 85vw;margin-left:200px;" class="out">
    <el-tabs
      type="border-card"
      style=" background-color:rgba(250,250,250,0.5);"
    >
      <el-tab-pane label="众筹">
        <div
          class="content1"
          v-for="(item, i) in data1.slice(
            (currentPage - 1) * pagesize,
            currentPage * pagesize
          )"
          :key="i"
        >
          <h5>众筹金额：￥{{ item.cfTotalAmount }}</h5>
          <h4>{{ item.cfName }}</h4>
          <h6>{{ item.cfDeadline }}</h6>
          <p style="margin-bottom: 10px;">
            {{ item.cfIntroduce }}
          </p>
          <span class="a" @click="routerTo('/dream', item.cfId)"
            >点击查看集资详情</span
          >
          <br />
          <el-image
            v-if="item.cfImage"
            fit="contain"
            :src="item.cfImage"
            class="image"
          >
          </el-image>
        </div>
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage"
            :page-size="pagesize"
            layout="prev, pager, next, jumper"
            :total="pagetotal"
            background
            hide-on-single-page
          >
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="募捐" class="text">
        <el-card
          class="box-card"
          v-for="(item, o) in data2.slice(
            (currentPage2 - 1) * pagesize2,
            currentPage2 * pagesize2
          )"
          :key="o"
        >
          <div class="content2">
            <h4>受捐赠人：{{ item.name }}</h4>
            <h4>就读年级：{{ item.learningSection }}</h4>
            <h4>就读学校：{{ item.school }}</h4>
            <h4>家庭住址：{{ item.receivingAddress }}</h4>
            <h4>发布时间：{{ item.createTime }}</h4>
            <h4>筹集金额：￥{{ item.totalMoney }}</h4>
            <span
              class="a"
              @click="routerTo('/charity/persondonation', item.recipientId)"
              >点击查看受助人信息</span
            >
            <h2
              v-if="item.status == 0"
              style="color:rgb(243, 206, 41)"
              @click="routerTo('/charity/stucharity', item.recipientId)"
            >
              审核中
            </h2>
            <h2
              v-else-if="item.status == 1"
              style="color:rgb(127,204,89);"
              @click="routerTo('/charity/stucharity', item.recipientId)"
            >
              审核通过
            </h2>
            <h2
              v-else
              @click="routerTo('/charity/stucharity', item.recipientId)"
            >
              审核未通过
            </h2>
            <el-button
              @click="routerTo('/charity/publishpage', item.recipientId)"
              type="success"
              plain
              v-if="item.status == 1"
              style="float:left;margin-top: 5px;"
              >发布公示信息</el-button
            >
          </div>
        </el-card>
        <!-- <div
          class="content1"
          v-for="(item, i) in data2.slice(
            (currentPage2 - 1) * pagesize2,
            currentPage2 * pagesize2
          )"
          :key="i"
        >
          <h5>募捐到金额：￥{{ item.totalMoney }}</h5>
          <h4>受捐赠人：{{ item.name }}</h4>
          <h6>{{ item.createTime }}</h6>
          <p style="margin-bottom: 10px;">
            {{ item.text }}
          </p>
          <span
            class="a"
            @click="routerTo('/charity/persondonation', item.recipientId)"
            >点击查看集资详情</span
          >
          <br />
        </div> -->
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange2"
            @current-change="handleCurrentChange2"
            :current-page.sync="currentPage2"
            :page-size="pagesize2"
            layout="prev, pager, next, jumper"
            :total="pagetotal2"
            background
            hide-on-single-page
          >
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import {
  getMyInfo,
  getCrowdFundingListByuserName,
  getListByUserName
} from "@/network/profile.js";

export default {
  data() {
    return {
      username: "",
      pagesize: 5,
      pagesize2: 6,
      currentPage: 1,
      currentPage2: 1,
      pagetotal: 0,
      pagetotal2: 0,
      img: [[]],
      data1: [
        // {
        //   cfId: "1",
        //   cfName: "活动名称",
        //   cfDeadline: "2021-7-1 12:20:32",
        //   cfIntroduce:
        //     "活动内容Lorem ipsum dolor, sit amet consectetur adipisicing elit. Molestias, id assumenda impedit corporis rem ratione, labore temporibus aliquid eligendi maiores ullam asperiores dicta deleniti cupiditate accusantium veritatis voluptatem culpa laboriosam?",
        //   cfImage: [
        //     "https://img0.baidu.com/it/u=2151136234,3513236673&fm=26&fmt=auto&gp=0.jpg",
        //     "https://img0.baidu.com/it/u=2635130093,4202492912&fm=26&fmt=auto&gp=0.jpg"
        //   ]
        // }
      ],
      data2: [
        // {
        //   recipientId: "2",
        //   name: "姓名",
        //   time: "2021-7-1 12:20:32",
        //   detail:
        //     "活动内容Lorem ipsum dolor, sit amet consectetur adipisicing elit. Molestias, id assumenda impedit corporis rem ratione, labore temporibus aliquid eligendi maiores ullam asperiores dicta deleniti cupiditate accusantium veritatis voluptatem culpa laboriosam?",
        //   image: [
        //      "https://img0.baidu.com/it/u=480941639,3775135897&fm=26&fmt=auto&gp=0.jpg",
        //     "https://img0.baidu.com/it/u=1813239583,4251715209&fm=26&fmt=auto&gp=0.jpg"
        //   ],
        //   srcList: [
        //     "https://img0.baidu.com/it/u=480941639,3775135897&fm=26&fmt=auto&gp=0.jpg",
        //     "https://img0.baidu.com/it/u=1813239583,4251715209&fm=26&fmt=auto&gp=0.jpg"
        //   ]
        // }
      ]
    };
  },
  created() {
    this.getMyInfo();
    this.getCrowdFundingListByuserName();
  },
  mounted() {},
  methods: {
    getMyInfo() {
      getMyInfo().then(res => {
        // console.log("username");
        // console.log(res.data.infoVo.username);
        this.username = res.data.infoVo.username;
        getListByUserName(this.username).then(res => {
          // console.log("募捐：");
          // console.log(res);
          this.data2 = res;
          this.pagetotal2 = this.data2.length;
        });
      });
    },
    getCrowdFundingListByuserName() {
      getCrowdFundingListByuserName().then(res => {
        // console.log("发布：");
        // console.log(res);
        this.data1 = res;
        this.pagetotal = this.data1.length;
        for (var i in this.data1) {
          // console.log(this.data1[i].cfImage);
          this.img[i] = this.data1[i].cfImage;
          if (!this.data1[i].cfIntroduce) {
            this.data1[i].cfIntroduce =
              "活动内容Lorem ipsum dolor, sit amet consectetur adipisicing elit. Molestias, id assumenda impedit corporis rem ratione, labore temporibus aliquid eligendi maiores ullam asperiores dicta deleniti cupiditate accusantium veritatis voluptatem culpa laboriosam?";
          }
        }
        // console.log(this.img);
      });
    },

    routerTo(routerPath, id) {
      // console.log(id);
      this.$router.push({
        path: routerPath,
        query: {
          id: id
        }
      });
    },
    handleSizeChange(val) {
      this.pagesize = val;
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      console.log(`当前页: ${val}`);
    },
    handleSizeChange2(val) {
      this.pagesize2 = val;
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange2(val) {
      this.currentPage2 = val;
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style scoped lang="scss">
/deep/ .el-tabs--border-card > .el-tabs__header {
  background-color: #f1e3df;
}
/deep/ .el-tabs--border-card > .el-tabs__header .el-tabs__item {
  color: rgb(160, 116, 100);
  font-size: 3vh;
}
.content {
  left: 180px;
  position: absolute;
  margin: 10px;
  margin-right: 3vw;
  // min-width: 900px;
  /* max-width: 85vw; */
  margin-top: -20px;
}
.menu {
  font-size: 3.2vh;
}
.content1 {
  padding-bottom: 1vh;
  padding-top: 1vh;
  border-bottom: 0.5vh solid #bbb;
}
.content1 h4 {
  margin-top: 10px;
  font-size: 2.8vh;
}
.content1 h5 {
  float: right;
  font-size: 2.4vh;
  color: red;
  margin-right: 3vw;
  margin-top: 1vh;
}
.content1 h6 {
  margin: 5px;
  font-size: 1.8vh;
}
.content1 p {
  text-indent: 2em;
  font-size: 2.4vh;
}
.content1 .a {
  text-decoration: underline;
  color: rgb(64, 150, 184);
  font-size: 2.6vh;
  margin-left: 3vw;
  cursor: pointer;
}
.content1 .image {
  width: 300px;
  margin-right: 10px;
  margin-top: 2vh;
}
.block {
  /* margin-top: 10px; */
  text-align: center;
}
.content2 {
  margin: 10px;
  padding-bottom: 10px;
  margin-bottom: 15px;
}
.content2 .a {
  text-decoration: underline;
  color: rgb(64, 150, 184);
  font-size: 2.6vh;
  cursor: pointer;
}
.content2 h4 {
  margin-bottom: 8px;
  font-size: 2.5vh;
}
.content2 h2 {
  color: red;
  float: right;
  cursor: pointer;
}
.box-card {
  width: 450px;
  display: inline-block;
  margin: 10px;
  box-shadow: 5px 5px 10px 3px #aaa;
  border-radius: 5%;
  background-color: rgba($color: #fff, $alpha: 0.3);
  text-align: left;
}
.text {
  text-align: center;
}
</style>
